﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NutriLeaf.Web.Core.Recipe
{
    public class RecipieRead:IRecipeRead
    {
        public void ReadRecipe(int userId, int recipeId, ref Model.NutriLeafDBEntities context)
        {
            Model.RecipeRead r = new Model.RecipeRead();
            r.UserID = userId;
            r.RecipeID = recipeId;
            context.RecipeReads.AddObject(r);
            context.SaveChanges();
        }

        public void RemoveRecentRead(int userId, ref Model.NutriLeafDBEntities context)
        {
            context.DeleteObject(context.RecipeReads.Where(p => p.UserID == userId).First());
            context.SaveChanges();
        }

        public void RemoveRead(int recipeReadId, ref Model.NutriLeafDBEntities context)
        {
            context.DeleteObject(context.RecipeReads.Where(p => p.RecipeReadID == recipeReadId).First());
            context.SaveChanges();
        }

        public List<Model.Recipe> GetRecipeMostRead(int userId, ref Model.NutriLeafDBEntities context)
        {
            //doubt
            throw new NotImplementedException();
        }
    }
}